
Simon Parzer
Member #3,330
March 2003
avatar

	
Posted on 11-26-2006 2:49 PM   View Profile
You don't need a tutorial for that. Just make a Server class and a Client class and you're done.

Something like this (pseudocode)

Client:
-------
+ void connect(long serverIP, short port)
+ bool connected()
+ sendMSG(string message)

Server:
-------
+ void start()
- void handleConnection(long clientIP)

It's obvious how the client works (connect to connect to the server, sendMSG to send a message). To run the server you execute server.start() which starts a new thread that just waits for new connections. Everytime a client connects it runs this.handleConnection(ip) which spawns a thread for the new connection. In the meantime the "wait for new connections" thread continues. That way you have one listener thread and one thread per connection -- the classical multi-threaded server.

You can make it even simpler: Only allow one connection. But that would be too easy ;D.
--